package net.frenopatico.citadels.controller.impl;

import javax.inject.Inject;

import net.frenopatico.citadels.controller.IPlayersService;
import net.frenopatico.citadels.manager.IPlayerManager;

import com.google.appengine.api.datastore.EntityNotFoundException;

/**
 * Implementation of service to control the access to Players services.
 *
 * @author eduardo.ramirez.ronco@gmail.com
 *
 */
public class PlayersServiceImpl implements IPlayersService {
    @Inject private transient IPlayerManager playerMngr;

    /**
     * {@inheritDoc}
     */
    public boolean exists( final String email ) {
        boolean entityExists;
        try {
            playerMngr.get( email );
            entityExists = true; // NOPMD
        } catch( EntityNotFoundException e ) {
            entityExists = false;
        }
        return entityExists;
    }
}
